package com.itheima.contoller;

import com.itheima.dto.SearchDto;
import com.itheima.pojo.Good;
import com.itheima.service.SearchService;
import com.itheima.support.Result;
import com.itheima.support.ResultBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.List;

/**
 * @author YYP
 * @date 2020/12/19
 */
@RestController
@RequestMapping("/good")
public class SearchController {

    @Autowired
    private SearchService searchService;

    @PostMapping("/search")
    public Result search(@RequestBody SearchDto searchDto) throws IOException {
        System.out.println(searchDto);
        /*List<Good> goods = searchService.goodsSearch(keyword);
        for (Good good : goods) {
            System.out.println(good);
        }*/
        return new Result(searchService.goodsSearch(searchDto).getData(),searchService.goodsSearch(searchDto).getTotal());
        //return ResultBuilder.build(searchService.goodsSearch(keyword));
    }

}
